<?php

/*
 * Fresns Control Panel (Standalone)
 * Copyright (C) 2021-Present 刘鑫
 * Released under the MIT License.
 */

use App\Http\Center\Helper\PluginHelper;

if (PluginHelper::pluginCanUse('FcpApi')) {
    // 管理员
    Route::group(['prefix' => 'admin', 'middleware' => 'auth:api', 'namespace' => '\App\Plugins\FcpApi\TweetAdmin'], function () {
        Route::get('/admin/index', 'FsControllerAdmin@index')->name('admin.admin.index');
        Route::post('/admin/store', 'FsControllerAdmin@store')->name('admin.admin.store');
        Route::post('/admin/update', 'FsControllerAdmin@update')->name('admin.admin.update');
        Route::post('/admin/destroy', 'FsControllerAdmin@destroy')->name('admin.admin.destroy');
        Route::get('/admin/detail', 'FsControllerAdmin@detail')->name('admin.admin.detail');
        // 查询非管理员用户
        Route::get('/admin/searchUser', 'FsControllerAdmin@searchUser')->name('admin.admin.searchUser');
        // 新增管理员
        Route::post('/admin/storeAdmin', 'FsControllerAdmin@storeAdmin')->name('admin.admin.storeAdmin');
        // 删除管理员
        Route::post('/admin/destroyAdmin', 'FsControllerAdmin@destroyAdmin')->name('admin.admin.destroyAdmin');
        // 重置密码
        Route::post('/admin/resetPassword', 'FsControllerAdmin@resetPassword')->name('admin.admin.resetPassword');
        // 更新密码
        Route::post('/admin/updatePassword', 'FsControllerAdmin@updatePassword')->name('admin.admin.updatePassword');
        // 退出登录
        Route::post('/adminLogout', 'LoginController@adminLogout')->name('admin.admin.adminLogout');
    });
    // 登录后请求
    Route::group(['middleware' => 'auth:api', 'namespace' => '\App\Plugins\FcpApi\TweetAdmin'], function () {
        Route::get('/currentUser', 'LoginController@currentUser')->name('admin.admin.currentUser');
    });
    // 免登录请求
    Route::group(['prefix' => 'admin', 'namespace' => '\App\Plugins\FcpApi\TweetAdmin'], function () {
        Route::post('/adminLogin', 'LoginController@adminLogin')->name('admin.admin.adminLogin');
    });
}